package cn.thoughtworks.school.contract;

import cn.thoughtworks.school.Application;
import cn.thoughtworks.school.services.JenkinsService;
import com.github.database.rider.core.api.configuration.DBUnit;
import com.github.database.rider.core.api.dataset.DataSet;
import com.github.database.rider.spring.api.DBRider;
import io.restassured.module.mockmvc.RestAssuredMockMvc;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.WebApplicationContext;

import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;


@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
//@AutoConfigureStubRunner(ids = "cn.thoughtworks.school:userCenterBackend:+:stubs:10001", repositoryRoot = "http://ec2-54-222-235-15.cn-north-1.compute.amazonaws.com.cn:8081/repository/maven-snapshots/")
@ActiveProfiles("test")
@Transactional
@DBRider
@DBUnit(caseSensitiveTableNames = true)
@DataSet("singlestackprogrammingquizsubmission.yml")
public class SingleStackProgrammingQuizSubmissionBase {

    @Autowired
    private WebApplicationContext wac;
    @MockBean
    private JenkinsService jenkinsService;

    @Before
    public void setup() {
        when(jenkinsService.triggerSingleStackProgrammingQuizSubmissionJob(anyString()
                , anyString(), anyString(), anyString(), anyString())).thenReturn(HttpStatus.CREATED);
        RestAssuredMockMvc.webAppContextSetup(wac);
    }
}
